////
////  HXLoginViewController.m
////  NewProject
////
////  Created by Livespro on 2017/5/3.
////  Copyright © 2017年 FZ. All rights reserved.
////
//
//#import "HXLoginViewController.h"
//
//#import "HXFriendListViewController.h"
//
//@interface HXLoginViewController ()
//
//@property (nonatomic, strong)  UITextField *loginName;//登录名
//
//@property (nonatomic, strong)  UITextField *loginPassword;//密码
//
//@property (nonatomic, strong)  UIButton *signIn;//登录
//
//@property (nonatomic, strong)  UIButton *signUp;//注册
//
//@property (nonatomic, strong)  UIButton *autoLogin;//自动登录
//
//@property (nonatomic, strong)  UIButton *codeProtect;//密码保护
//
//@end
//
//@implementation HXLoginViewController
//
//- (void)viewDidLoad {
//    [super viewDidLoad];
//    // Do any additional setup after loading the view.
//    
//}
//
//- (void)staticViewsWithoutNib;{
//    
//    self.naviStand.title = @"Login";
//   
//    [self.view addSubview:self.loginName];
//    [self.view addSubview:self.loginPassword];
//    
//    [self.view addSubview:self.codeProtect];
//    [self.view addSubview:self.autoLogin];
//    
//    [self.view addSubview:self.signUp];
//
//    [self.view addSubview:self.signIn];
//    
//    [self frameLayout];
//    
//}
//
//- (void)frameLayout{
//    
//    CGFloat beginHeight = 64 + kScreenHeight/6;
//    
//    self.loginName.frame = CGRectMake(kScreenWidth/6, beginHeight, kScreenWidth *2/3, 50);
//    
//    beginHeight += CGRectGetHeight(self.loginName.frame) + 20;
//    
//    self.loginPassword.frame = CGRectMake(CGRectGetMinX(self.loginName.frame),beginHeight,CGRectGetWidth(self.loginName.frame),50);
//    
//    self.codeProtect.frame = CGRectMake(CGRectGetMaxX(self.loginPassword.frame) + 10, beginHeight + (CGRectGetHeight(self.loginPassword.frame) - 15)/2 , 15, 15);
//    
//    beginHeight += CGRectGetHeight(self.loginPassword.frame) + 10;
//    
//    self.autoLogin.frame = CGRectMake(CGRectGetMinX(self.loginName.frame), beginHeight, 80, 15);
//    
//    beginHeight += CGRectGetHeight(self.autoLogin.frame) + 10;
//    
//    self.signUp.frame = CGRectMake(CGRectGetMinX(self.loginName.frame) +10,beginHeight, 80, 40);
//    
//    self.signIn.frame = CGRectMake(CGRectGetMaxX(self.loginName.frame) - 90, beginHeight, 80, 40);
//}
//
//
//#pragma mark - lazyLoad.
//
//- (UITextField *)loginName{
//    
//    if (!_loginName) {
//        
//        _loginName = [[UITextField alloc]initWithFrame:CGRectZero];
//        _loginName.borderStyle = UITextBorderStyleRoundedRect;
//        _loginName.placeholder = @"账号";
//        
//    }
//    
//    return _loginName;
//}
//
//- (UITextField *)loginPassword{
//    
//    if (!_loginPassword) {
//        
//        _loginPassword = [[UITextField alloc]initWithFrame:CGRectZero];
//        _loginPassword.borderStyle = UITextBorderStyleRoundedRect;
//        _loginPassword.placeholder = @"密码";
//        
//    }
//    return _loginPassword;
//}
//
//- (UIButton *)signIn{
//    
//    if (!_signIn) {
//        
//        _signIn = [UIButton buttonWithDic:@{@"text" : @"登录",@"textColor":Colorfff,@"backgroundColor":naviColor} Target:self Selector:@selector(signInAction)];
//        
//        [_signIn setRadius:6 borderWidth:0 borderColor:[UIColor clearColor]];
//    }
//    return _signIn;
//}
//
//- (UIButton *)signUp{
//    
//    if (!_signUp) {
//        
//        _signUp = [UIButton buttonWithDic:@{@"text" : @"注册",@"textColor":Colorfff,@"backgroundColor":naviColor} Target:self Selector:@selector(signUpAction)];
//        
//        [_signUp setRadius:6 borderWidth:0 borderColor:[UIColor clearColor]];
//    }
//    return _signUp;
//}
//
//- (UIButton *)codeProtect{
//    
//    if (!_codeProtect) {
//        
//        _codeProtect = [UIButton buttonWithCustomTypeNomalImage:@"code" Frame:CGRectZero];
//        
//        [_codeProtect setImage:[[UIImage imageNamed:@"code"] rt_tintedImageWithColor:naviColor] forState:UIControlStateSelected];
//        _codeProtect.selected = YES;
//        
//        //扩展点击区域
//        _codeProtect.isOverStepTouch = YES;
//        _codeProtect.hitTestEdgeInsets = UIEdgeInsetsMake(10, 10, 10, 10);
//        
//        //action - 是否保护输入
//        __weak typeof(self) weakSelf = self;
//        [[_codeProtect rac_signalForControlEvents:UIControlEventTouchUpInside] subscribeNext:^(__kindof UIControl * _Nullable x) {
//            
//            weakSelf.codeProtect.selected = !weakSelf.codeProtect.selected;
//            
//            weakSelf.loginPassword.secureTextEntry = weakSelf.codeProtect.selected;
//            
//        }];
//    }
//    
//    return _codeProtect;
//}
//
//- (UIButton *)autoLogin{
//    
//    if (!_autoLogin) {
//        
//        _autoLogin = [UIButton buttonWithCustomTypeAndNomalStateTitle:@"自动登录" TitleFont:12 TitleColor:Color666 BackgroundColor:[UIColor clearColor] Frame:CGRectZero Image:@"choose_false"];
//        
//        _autoLogin.imageEdgeInsets = UIEdgeInsetsMake(0, -10, 0, 0);
//        
//        [_autoLogin setImage:[UIImage imageNamed:@"choose_true"] forState:UIControlStateSelected];
//        _autoLogin.selected = YES;
//        
//        [EMClient sharedClient].options.isAutoLogin = self.autoLogin.selected;
//        
//        //action - 是否自动登录
//        __weak typeof(self) weakSelf = self;
//        [[_autoLogin rac_signalForControlEvents:UIControlEventTouchUpInside] subscribeNext:^(__kindof UIControl * _Nullable x) {
//            
//            weakSelf.autoLogin.selected = !weakSelf.autoLogin.selected;
//            [EMClient sharedClient].options.isAutoLogin = weakSelf.autoLogin.selected;
//            
//        }];
//        
//    }
//    return _autoLogin;
//}
//
//#pragma mark - Action -
//
//
///**
// 登录
// */
//- (void)signInAction{
//    
//    __weak typeof(self) weakSelf = self;
//    [[EMClient sharedClient] loginWithUsername:self.loginName.text
//                                      password:self.loginPassword.text
//                                    completion:^(NSString *aUsername, EMError *aError) {
//                                        
//                                        [weakSelf.view endEditing:YES];
//                                        if (!aError) {
//                                            [weakSelf showHint:@"登录成功"];
//                                            
//                                            [weakSelf performSelector:@selector(jumpListAction) withObject:nil afterDelay:.5];
//                                            
//                                        } else {
//                                            [weakSelf showHint:aError.errorDescription];
//                                        }
//                                    }];
//    
//}
//
///**
// 注册
// */
//- (void)signUpAction{
//    
//    [self.view endEditing:YES];
//    
//    __weak typeof(self) weakSelf = self;
//    
//    [self.view beginLoading];
//    [[EMClient sharedClient] registerWithUsername:self.loginName.text password:self.loginPassword.text completion:^(NSString *aUsername, EMError *aError) {
//        
//        [weakSelf.view endLoading];
//        
//        if (!aError) {
//            
//            [weakSelf showHint:@"注册成功"];
//            
//            [weakSelf performSelector:@selector(jumpListAction) withObject:nil afterDelay:.5];
//            
//        }else{
//            
//            [weakSelf showHint:aError.errorDescription];
//        }
//
//        
//    }];
//}
//
//
///**
// * 跳转
// */
//- (void)jumpListAction{
//    
//    __weak typeof(self) weakSelf = self;
//    [self dismissViewControllerAnimated:YES completion:^{
//        
//        __strong typeof(self) strongSelf = weakSelf;
//        if (strongSelf.loginSuccess) {
//            
//            strongSelf.loginSuccess();
//        }
//    }];
//}
//
//- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
//    
//    [self.view endEditing:YES];
//}
//
//@end

